package com.comon.core.utils;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-08-24
 * Time:14:47
 * Text：BCrypt 算法进行加密
 */

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class BCryptUtils {
    /**
     * @description: 加密
     * @author: TQ02 
     * @date: 2024/8/13 22:51
     * @param: password
     * @return: String
     **/
    public static String encryptPassword(String password){
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        return passwordEncoder.encode(password);
    }


  
    /**
     * @description:
     * @author: tq02
     * @date: 2024/8/13 23:01
     * @param rawPassword
     * @param encodedPassword
     * @return: boolean
    **/
    public static boolean matchesPassword(String rawPassword,String encodedPassword){
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        return passwordEncoder.matches(rawPassword,encodedPassword);
    }

}
